package com.dubbo.user.service;

import com.dubbo.goods.api.GoodsDubboService;
import com.dubbo.goods.domain.GoodsDTO;
import com.dubbo.user.api.UserDubboService;
import com.dubbo.user.domain.UserDO;
import com.dubbo.user.domain.UserDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author user
 * @create 2017-11-16 12:00
 */
@Service("userService")
public class UserServiceImpl implements UserService, UserDubboService {

    @Autowired
    private GoodsDubboService goodsDubboService;

    @Override
    public UserDTO findAllUser() {
        UserDO userDO = new UserDO();
        userDO.setId(1L);
        userDO.setName("user");
        userDO.setPassword("DKHhb3213ijhff");

        UserDTO userDTO = new UserDTO();
        BeanUtils.copyProperties(userDO, userDTO);

        GoodsDTO goodsDTO = goodsDubboService.findAllGoodsDubbo();
        userDTO.setGoodsDTO(goodsDTO);
        return userDTO;
    }

    @Override
    public UserDTO findAllUserDubbo() {
        return findAllUser();
    }
}
